<?php
   class ApiCenter_SalesApi_Model_Api2_Orderdata_Confirmorderdata_Rest extends ApiCenter_SalesApi_Model_Api2_Orderdata_Confirmorderdata{
    
       
       //获取商家所有的主订单列表
       protected  function _getOrderForCollection($vendorId,$filter=null){
           
               
                    /** @var $collection ApiCenter_SalesApi_Model_Resource_Mysql4_Order_Item_Collection */
                   $collection = Mage::getResourceModel('sales/order_item_collection');
                   $collection->addFieldToFilter("main_table.vendor_id",$this->_loadVendor($vendorId)->getId());
                   $collection->addFieldToFilter("main_table.parent_item_id",array('null' => ''));
                   $collection->addFieldToFilter("d.status","payment_success");
                   $collection->addFieldToSelect("sku");
                   $collection->getSelect()
                   ->joinLeft(array('d' => 'sales_flat_order'),
                       'd.entity_id = main_table.order_id',
                       array(
                           "increment_id"=>"d.increment_id",
                           "main_created_at"=>"d.created_at",
                           "status"=>"d.status"
                       ))
                   ->joinLeft(array('f' => 'tb_sales_flat_order'),
                       'LEFT(f.increment_id,9) = d.increment_id AND (`main_table`.`vendor_id` = `f`.`vendor_id`)',
                       array(
                           "fincrement_id"=>"f.increment_id",
                       ))
                   ->group("main_table.order_id")    
                     ->where(" f.increment_id is null");
                   
                   if($filter){
                       foreach ($filter as $filterEntry) {
                           $attributeCode = $filterEntry['attribute'];
                           unset($filterEntry['attribute']);
                           $collection->addFieldToFilter($attributeCode, $filterEntry);
                       }
                   }
            
           return $collection;
       }
       
       
     
  }